package com.template.app.utils;

import com.template.app.bean.DataTableRequest;


public class QueryOrderUtil {
	
	public static String orderBy(DataTableRequest dataTableRequest) {
		String by ="";
		if(CommonUtil.isNotEmpty(dataTableRequest.getOrder())){
			DataTableRequest.Order order = dataTableRequest.getOrder()[0];
			DataTableRequest.Column[] columes = dataTableRequest.getColumns();
			String dir = order.getDir();//DESC ASC
			DataTableRequest.Column column = columes[order.getColumn()];
			String cdata = column.getData();
			String data = cdata.equals("") ? "id":cdata;
			by = data +" "+dir;//order by data desc
		}
		return by;
	}
}
